package com.tz.dao;

import com.tz.entity.Faq;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Administrator on 2016/8/5.
 */
@Repository
@Transactional
public class FaqDaoImpl implements FaqDao{
    @Autowired
    private SessionFactory sessionFactory;

    private Session getSession() {
        return sessionFactory.getCurrentSession();
    }
    @Override
    public List<Faq> getAll() {
        String hql = "from Faq";
        return getSession().createQuery(hql).list();
    }

    @Override
    public void save(Faq f) {
        getSession().save(f);
    }
}
